import type { IPaginationPlatformConfig } from '../../../../module/page_enhancer/interaction/auto_pagination/service/config/types'

/**
 * 页面类型
 */
export enum BianPageType {
  List = 'list',
  Detail = 'detail',
  NotFound = 'not-found',
  Undefined = 'undefined',
}

/**
 * 页面类型属性
 */
export interface BianPageTypeResult {
  type: BianPageType | 'default'
}

// ====================================================== 基础配置 ======================================================
export const DEFAULT_PAGINATION_CONTAINER_SELECTOR: string = '#main .page'
export const DEFAULT_LIST_CONTAINER_SELECTOR: string = '#main .slist ul'
export const BIAN_LIST_ITEM_SELECTOR: string = '#main .slist ul > li:not(.nextpage)'
export const BIAN_PAGINATION_CONFIG: IPaginationPlatformConfig = {
  className: {
    previousPage: '',
    nextPage: '',
    currentPage: '',
    allPage: '',
  },
  childSelector: {
    previousPage: 'a:contains("上一页")',
    nextPage: 'a:contains("下一页")',
    currentPage: 'b',
    allPage: 'a:not(#jump-url)',
  },
  selector: {
    container: DEFAULT_PAGINATION_CONTAINER_SELECTOR,
    previousPage: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} a:contains("上一页")`,
    nextPage: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} a:contains("下一页")`,
    currentPage: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} b`,
    item: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} :is(a:not(#jump-url), b)`,
    link: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} > a:not(#jump-url)`,
  },
  list: {
    header: '',
    container: DEFAULT_LIST_CONTAINER_SELECTOR,
    item: `${DEFAULT_LIST_CONTAINER_SELECTOR} > li`,
  },
}
